package com.nidu.demo.dept;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.dept.api.SysDepartmentService;
import com.nidu.demo.dept.dto.*;
import com.nidu.demo.dept.executor.command.*;
import com.nidu.demo.dept.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 部门服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysDepartmentServiceImpl implements SysDepartmentService {

    private final DepartmentAddCmdExe addCmdExe;
    private final DepartmentUpdateCmdExe updateCmdExe;
    private final DepartmentDeleteCmdExe deleteCmdExe;
    private final DepartmentSingleQryExe singleQryExe;
    private final DepartmentListQryExe listQryExe;
    private final DepartmentPageQryExe pageQryExe;

    @Override
    public SingleResponse<DepartmentCO> add(DepartmentAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<DepartmentCO> update(DepartmentUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<DepartmentCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<DepartmentCO> list(DepartmentListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public MultiResponse<DepartmentTreeCO> tree(DepartmentTreeQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<DepartmentTreeCO> page(DepartmentPageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        return updateCmdExe.updateStatus(id, status);
    }

} 